#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;

//int main() {
//    int a, b;
//    while (cin >> a >> b)
//    {
//        long long ret = 0;
//        int max = a > b ? a : b;
//        int min = a + b - max;
//
//        int i = 1;
//        for (i = 1; i <= min; ++i)
//        {
//            ret = i * max;
//            if (ret % min == 0)
//                break;
//        }
//        cout << ret << endl;
//
//    }
//    return 0;
//}

class Solution {
public:

    int MLS(vector<int>& arr)
    {
        if (arr.size() <= 1)
            return arr.size();

        set<int> s(arr.begin(), arr.end());

        int ret = 1;
        set<int>::iterator it = s.begin();
        set<int>::iterator fast = ++s.begin();

        while (fast != s.end())
        {
            if (fast != s.end() && *fast - *it == 1)
            {
                int cur = 0;
                while (fast != s.end() && *fast - *it == 1)
                {
                    ++cur;
                    ++fast;
                    ++it;
                }
                ++cur;
                if(fast != s.end())
                    ++fast;
                ++it;
                if (cur > ret)
                    ret = cur;
            }
            else
            {
                ++it;
                ++fast;
            }
        }
        return ret;
    }
};
//int main()
//{
//    vector<int> v = { 0, -1 };
//    cout << Solution().MLS(v) << endl;
//    return 0;
//}


int main() {
    int n, m;
    while (cin >> n >> m)
    {
        vector<vector<int>> v;
        v.reserve(n);
        for (int i = 0; i < n; ++i)
        {
            vector<int> tmp(m, 0);
            v.push_back(tmp);
            for (int j = 0; j < m; ++j)
            {
                char c;
                cin >> c;
                if (c == 'l')
                    v[i][j] = 4;
                else if (c == 'o')
                    v[i][j] = 3;
                else if (c == 'v')
                    v[i][j] = 2;
                else if (c == 'e')
                    v[i][j] = 1;
            }
        }

        vector<vector<int>> dp;
        dp.reserve(n + 1);
        for (int i = 0; i <= n; ++i)
        {
            vector<int> tmp(m + 1, 0);
            dp.push_back(tmp);
        }

        for (int i = 1; i <= n; ++i)
        {
            for (int j = 1; j <= m; ++j)
            {
                int max = dp[i - 1][j] > dp[i][j - 1] ? dp[i - 1][j] : dp[i][j - 1];
                dp[i][j] = max + v[i - 1][j - 1];
            }
        }

        cout << dp[n][m] << endl;
    }
    return 0;
}